//
//  LCZFullScreenMovieController.m
//  PersonalNews
//
//  Created by Golibyo on 15/12/3.
//  Copyright © 2015年 changshuhua. All rights reserved.
//

#import "LCZFullScreenMovieController.h"
#import "LCZAVPlayer.h"

@interface LCZFullScreenMovieController ()

@property(nonatomic, strong)LCZAVPlayer *avplayerView;
@end



@implementation LCZFullScreenMovieController

#pragma mark - 横屏代码
- (BOOL)shouldAutorotate{
    return NO;
} //NS_AVAILABLE_IOS(6_0);当前viewcontroller是否支持转屏

- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
    
    return UIInterfaceOrientationMaskLandscape;
} //当前viewcontroller支持哪些转屏方向

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight;
}

- (BOOL)prefersStatusBarHidden
{
    return NO; // 返回NO表示要显示，返回YES将hiden
}

- (void)viewDidLoad {
//    self.view.backgroundColor = [UIColor clearColor];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(HEIGHT / 667.0 * 627, 0, 40, 40);
//    button.backgroundColor = [UIColor cyanColor];
    [button setBackgroundImage:[UIImage imageNamed:@"quitFullScreenMode.png"] forState:UIControlStateNormal];
    [LCZAVPlayer shareSingleton].frame = CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width);
    [[LCZAVPlayer shareSingleton] changeFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
    [self.view addSubview:[LCZAVPlayer shareSingleton]];
    [self.view addSubview:button];
    [LCZAVPlayer shareSingleton].startButton.hidden = YES; 
    [button addTarget:self action:@selector(returnClick:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)returnClick:(UIButton *)button {
    [LCZAVPlayer shareSingleton].startButton.hidden = NO;
    [LCZSingleton shareSingleton].isReturnClick = YES;
    [LCZSingleton shareSingleton].willFullScreenAppear = NO;
    [self dismissViewControllerAnimated:YES completion:^{
        NSNotification * notice = [NSNotification notificationWithName:@"456" object:nil];
        //发送消息
        
        [[NSNotificationCenter defaultCenter]postNotification:notice];
        //发送消息
        
    }];
}


@end
